package com.dongdongshop.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbItemCatMapper;
import com.dongdongshop.pojo.item.TbItemCat;
import com.dongdongshop.pojo.item.TbItemCatExample;
import com.dongdongshop.service.ItemCatServiceI;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
@Service
public class ItemCatServiceImpl implements ItemCatServiceI {
    @Resource
    private TbItemCatMapper tbItemCatMapper;


    @Override
    public Long getTypeId(Long id) {
        return tbItemCatMapper.getTypeId(id);
    }

    @Override
    public List<TbItemCat> getItemParentId(Long parentId) {
        return tbItemCatMapper.getItemParentId(parentId);
    }

    @Override
    public void updateItemCat(TbItemCat tbItemCat) {
        tbItemCatMapper.updateByPrimaryKeySelective(tbItemCat);
    }

    @Override
    public TbItemCat getItemCat(Long id) {
        return tbItemCatMapper.selectByPrimaryKey(id);
    }

    @Override
    public void insertItemCat(TbItemCat tbItemCat) {
        tbItemCatMapper.insert(tbItemCat);
    }

    @Override
    public void deleteItemCat(Integer[] ids) {
        tbItemCatMapper.deleteItemCat(ids);
    }

    @Override
    public TbItemCat getItemById(Long id) {
        return tbItemCatMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<TbItemCat> itemCatList(Long parentId) {
        TbItemCatExample catExample=new TbItemCatExample();
        TbItemCatExample.Criteria criteria = catExample.createCriteria();
        criteria.andParentIdEqualTo(parentId);
        // return tbItemCatMapper.itemCatList(parentId);
        return tbItemCatMapper.selectByExample(catExample);
    }
}
